<?php defined('InShopNC') or exit('Access Invalid!');?>
<link href="<?php echo TEMPLATES_PATH;?>/css/home_cart.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?php echo RESOURCE_PATH;?>/js/jquery.validation.min.js"></script>
<header class="layout head padding-small">
    <a href="javascript:pageBack();" class="hBack float-left"></a>
    <h4 class="hTxt float-left text-center text-white">品牌充值</h4>
    <a href="javascript:;" id="btnJdkey" class="hHlep float-right"></a>
</header>

<div class="pay_main">
	<form action="index.php?act=alliance" method="POST" id="goto_pay">
	 <input type="hidden" name="brand_id" value="<?php echo $output['setting']['brand_id']; ?>" />
	<div class="all_order_price">
		<?php if($output['is_paid'] == 1){?>
		<input type="hidden" name="alliance_deposit" value="<?php echo $output['setting']['alliance_deposit']; ?>" />
		<?php echo $output['setting']['brand_name']; ?> 品牌加盟费用：<span class="order_price">&yen; <?php echo number_format($output['setting']['alliance_deposit'],2); ?></span>
		<?php }elseif($output['is_paid'] == 2){ ?>
		<input type="text" class="text" name="alliance_deposit" id="alliance_deposit" maxlength="10" value="" placeholder="充值金额"/>
		<?php } ?>
	</div>
	<div class="sel_pay_tit">
		<div class="bor_tit">选择支付方式</div>
	</div>
      
	  <div class="tabs-panel">
        <ul class="cart-defray">
          <?php if(!empty($output['payment_list']) && is_array($output['payment_list'])) { ?>
          <?php foreach($output['payment_list'] as $val) { ?>
          <?php 
		  	if($val['payment_code'] == 'wxpay'){
			 	$user_agent = $_SERVER['HTTP_USER_AGENT'];
				if (strpos($user_agent, 'MicroMessenger') === false) {
					continue;	//非微信内置浏览器不显示
				} else {
					// 获取版本号
					preg_match('/.*?(MicroMessenger\/([0-9.]+))\s*/', $user_agent, $matches);
					if($matches[2] < 5.0){
						continue;	//微信版本小于5.0不显示
					}
				}
			}
		 ?>
          <li>
            <label class="radio">
              	<input id="payment_<?php echo $val['payment_code']; ?>" class="radio_pay" type="radio" name="payment_id" value="<?php echo $val['payment_id']; ?>" extendattr="<?php echo $val['payment_code']; ?>" />
            	<span class="logo">
                	<img src="<?php echo SiteUrl?>/api/gold_payment/<?php echo $val['payment_code']; ?>/logo.gif" alt="<?php echo $val['payment_name']; ?>" title="<?php echo $val['payment_name']; ?>" />
                </span>
            </label>
          </li>
          <?php } ?>
          <?php } ?>
        </ul>
      </div>
	 <div id="show_error" style=" padding: 10px; text-align: center"></div>
	 <div class="pay_btn_area"><a href="javascript:void(0);" onclick="$('#goto_pay').submit();" class="pay_btn">确认支付</a></div>
  </form>
</div>

<script type="text/javascript">
$(function(){
	$('#goto_pay').validate({
        errorPlacement: function(error, element){
			$('#show_error').append(error);
        },
        rules : {
		   payment_id : {
	        	required  : true
	        },
		   alliance_deposit  : {
	        	required  : true,
			number    : true,
			min       : 0.01
            },
        },
        messages : {
		   payment_id      : {
                required:  '请选择支付方式'
            },
            alliance_deposit		: {
            	required  :'充值金额不能为空',
            	number    :'请输入数值',
                min    	  :'充值金额不能小于0.01元'
            }
        }
    });
});
</script>